package threadStudy;

public class YieldTest {
    public static void main(String[] args) {
        YieldStudy t1 = new YieldStudy("t1");
        YieldStudy t2 = new YieldStudy("t2");
        t1.start();
        t2.start();
    }
}

class YieldStudy extends Thread {
    YieldStudy(String s) {
        super(s);
    }

    @Override
    public void run() {
        for (int i = 0; i <= 30; i++) {
            System.out.println(getName() + ":" + i);
            if (("t1").equals(getName())) {
                if (i == 0) {
                    yield();
                }
            }
        }
    }
}